<?php
namespace app\admin\model;

use think\Model;

class Permission extends Model
{
    public function getPermission($permission_ids = ''){
        if($permission_ids){
            $permissions = db('permission')->where(['permission_id'=>['in',$permission_ids]])->select();
        }else{
            $permissions = db('permission')->select();
        }
        return $permissions;
    }
    //侧边菜单
    public function getMenus($permission_ids){
        $role_ids = explode(',',session('role_ids'));
        if(in_array(1,$role_ids)){
            $permissions = db('permission')->where(['type'=>0])->select();
        }else{
            $permissions = db('permission')->where(['permission_id' => ['in',$permission_ids],'type'=>0])->select();
        }
        return $permissions;
    }
}